﻿using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace AyuBookmark.Common.Models
{
    /// <summary>
    /// 系统通知消息实体
    /// </summary>
    [Table("Notifications")]
    public class Notification
    {
        /// <summary>
        /// 通知ID
        /// </summary>
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int Id { get; set; }

        /// <summary>
        /// 通知标题
        /// </summary>
        [Required]
        [StringLength(200)]
        public string Title { get; set; }

        /// <summary>
        /// 通知内容
        /// </summary>
        [Required]
        [Column(TypeName = "text")]
        public string Content { get; set; }

        /// <summary>
        /// 通知类型
        /// </summary>
        [Required]
        public NotificationType Type { get; set; }

        /// <summary>
        /// 通知级别
        /// </summary>
        [Required]
        public NotificationLevel Level { get; set; }

        /// <summary>
        /// 是否已读
        /// </summary>
        [Required]
        public bool IsRead { get; set; }

        /// <summary>
        /// 关联用户ID
        /// </summary>
        [ForeignKey("User")]
        public int UserId { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        [Required]
        public DateTime CreatedTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 阅读时间
        /// </summary>
        public DateTime? ReadTime { get; set; }

        /// <summary>
        /// 关联的用户实体
        /// </summary>
        public virtual User User { get; set; }

        /// <summary>
        /// 通知类型枚举
        /// </summary>
        public enum NotificationType
        {
            System = 0,     // 系统通知
            Bookmark = 1,   // 书签相关
            Update = 2,     // 更新通知
            Security = 3    // 安全通知
        }

        /// <summary>
        /// 通知级别枚举
        /// </summary>
        public enum NotificationLevel
        {
            Info = 0,       // 普通信息
            Warning = 1,    // 警告
            Urgent = 2      // 紧急
        }
    }
}